<template>
  <div class="lowin lowin-blue">
		<div class="lowin-brand">
			<img src="@/assets/kodinger.jpg" alt="logo">
		</div>
		<div class="lowin-wrapper">
			<div class="lowin-box lowin-login">
				<div class="lowin-box-inner">
          <h1 style="text-align:center; margin-bottom:2rem;">后台管理</h1>
          <div class="lowin-group">
            <el-input v-model="name" autocomplete="false" placeholder="用户名输入框"></el-input>
          </div>
          <div class="lowin-group password-group">
            <el-input type="password" autocomplete="false" v-model="password" placeholder="密码输入框"></el-input>
          </div>
          <button @click="onSubmits" class="lowin-btn login-btn">
            Sign In
          </button>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
import "@/assets/auth.css"
export default {
  name:'Login',
  data() {
    return {
      name:'',
      password:''
    }
  },
  methods:{
    testsss(){
      alert(111);
    },
    onSubmits(){
      this.$http.post('/validname',{name:this.name,password:this.password}).then(res=>{
        if(res.data.code==1){
          this.$success("welcome to"+this.name);
          sessionStorage.setItem('username',this.name)
          this.$go('/');
          this.name="";
          this.password="";
        }else{
          this.$fail('登录失败，请检查用户名和密码');
        }
      }).catch(err=>{
      if(err.message=="Network Error"){
        this.$fail('服务器异常，请稍后重试');
      }
      })
      
    }
  }
}
</script>

<style>
</style>